#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>

int main() {
    
    std::string data;
    std::cin >> data;
    
    std::vector<std::vector<size_t>> table(data.size());
    for (size_t i = 0; i < data.size(); ++i) {
        table[i].resize(data.size());
        for (size_t j = 0; j < data.size(); ++j){
            table[i][j] = 0;
        }
        table[i][i] = 1;
    }
    
    size_t maxLength = 1, maxL = 0, maxR = 0;
    std::string answer = "";
    
    for (int l = (int)data.size()-2; l >= 0; --l) {
        for (int r = 1; r < data.size(); ++r) {
            if (l<r){
                if (data[l] == data[r]) {
                    table[l][r] = table[l+1][r-1] + 2;
                }else{
                    table[l][r] = std::max(table[l+1][r], table[l][r-1]);
                }
                if (table[l][r] > maxLength) {
                    maxLength = table[l][r];
                    maxL = l;
                    maxR = r;
                }
            }
        }
    }
    
    size_t l = maxL, r = maxR;
    while(true){
        if (answer.length() == maxLength/2){
            break;
        }
        if (data[l] == data[r]){
            answer += data[r];
            l++; r--;
            continue;
        }
        if (table[l+1][r] > table[l][r-1])
            l++;
        else
            r--;
    }
    
    auto ansCopy = answer;
    if (maxLength%2)
        answer.push_back(data[l]);
    for (int i = (int)ansCopy.length()-1; i >= 0; --i){
        answer += ansCopy[i];
    }
    std::cout << maxLength << "\n" << answer;
    
    return 0;
}
